<?php

class Core_Agent_Component_Profile_Controller_Profile extends Dcmp_Component_Controller {
    
    public function informationAction(){
        Kd_Web::getPage()->setTitle('完善个人资料');
        Kd_Web::getPage()->getNavigation()->addLabel('完善个人资料');
        $model = App::getModel('permission/account')->loadByUsername($this->getIdentity()->getName());
        return $this->viewResult(array('model'=>$model));
    }

    public function informationPostAction(){
        $data = $this->getRequest()->getForm('content');
        $model = App::getModel('permission/account')->loadByUsername($this->getIdentity()->getName());
        if(strcasecmp($data['validate_code'],Kd_Web::getSession()->get('validate_code'))!=0){
            $this->getMessager()->addError($this->__('agent.label.error_validateimg'));
            return  $this->redirectResult($this->getUrl(NULL,'information'));
        }
//        if($_FILES['file']){
//            if ((($_FILES['file']["type"] == "image/gif") || ($_FILES['file']["type"] == "image/jpeg")
//                    || ($_FILES['file']["type"] == "image/pjpeg")) && ($_FILES['file']["size"]/1024 < 500)){
//                  if ($_FILES['file']["error"] > 0){
//                        $this->getMessager()->addError($this->__('agent.label.upload_fail'));
//                        return  $this->redirectResult($this->getUrl(NULL,'updateInformation'));
//                  }
//                  else{
//                        move_uploaded_file($_FILES['file']['tmp_name'],'E:/beta/pub/media/avatar/'.$_FILES['file']['name']);
//                        $model->setPicture('/pub/media/avatar/'.$_FILES['file']['name']);
//                  }
//            }
//            else{
//                  $this->getMessager()->addError($this->__('agent.label.upload_fail'));
//                  return  $this->redirectResult($this->getUrl(NULL,'updateInformation'));
//            }
//        }
        $model->setFullName($data['full_name'])->setEmail($data['email'])->setBirth($data['birth'])->setqq($data['qq'])->setAddress($data['address'])->save();
        $this->getMessager()->addInform($this->__('agent.label.change_success'));
        return  $this->redirectResult($this->getUrl(NULL,'index','index','index'));
    }

    
}